package com.pariyani.dao.impl;

import br.com.vantagensaki.utils.exception.ObjetoNaoEncontradoException;
import br.com.vantagensaki.utils.generics.impl.HibernateDaoGenerico;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pariyani.dao.UserDao;
import com.pariyani.user.User;

/**
 * @author Imran Pariyani
 * 
 * {@link http://pariyani.com} pariyani
 */
@Repository
@Component
public class UserDaoImpl extends HibernateDaoGenerico<User, Long> implements UserDao {

     public UserDaoImpl() {
        super(User.class);
    }

//    private EntityManager entityManagerFactory;

//    @PersistenceContext
//    void setEntityManager(EntityManager entityManager) {
//        this.entityManagerFactory = entityManager;
//    }

    
    @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
    public User getUser(int id) throws ObjetoNaoEncontradoException {
//        return (User) this.entityManagerFactory.find(User.class, id);
        return (User) this.getPorId(new Long(id));
    }
}